package cn.wolfcode.trip.base.domain;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 大攻略
 */
@Setter
@Getter
public class Strategy extends BaseDomain {

    public final static int STATE_COMMON = 0;   // 普通
    public final static int STATE_HOT = 1;  // 热门
    public final static int STATE_DISABLE = -1;   //禁用

    //所属地区
    private Region place;
    //标题
    private String title;
    //副标题
    private String subTitle;
    //封面
    private String coverUrl;
    //状态
    private Integer state = STATE_COMMON;
    // 攻略文章内容
    private StrategyContent strategyContent;
    //收藏数
    private Integer favoriteCount;
    //点赞数
    private Integer thumbupCount;
    //阅读数
    private Integer readCount;
    //加入旅行单时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    public String getStateName(){
        String temp = "普通";
        if(STATE_HOT == state){
            temp = "热门";
        }else if(STATE_DISABLE == state){
            temp = "禁用";
        }
        return temp;
    }
    //xx次浏览
    public String getReadCountName(){
        return readCount+"次浏览";
    }
    //xx次收藏
    public String getFavoriteCountName(){
        return favoriteCount+"次收藏";
    }

    public String getJson() {
        Map<String, Object> map = new HashMap();
        map.put("id", id);
        map.put("title", title);
        map.put("subTitle", subTitle);
        map.put("coverUrl", coverUrl);
        map.put("place", place);
        map.put("state", state);
        return JSON.toJSONString(map);
    }


}